#pragma once

namespace movesense {

#define SETTINGS_CHIP_ID                    0x0000

#define SETTINGS_WORK_STATUS		        0x0002
#define SETTINGS_UPDATE_STATUS            	SETTINGS_WORK_STATUS+3
#define SETTINGS_ERROR_STATUS		        0x0006
#define SETTINGS_WORK_START                 0x000A
#define SETTINGS_CMD                        0x000B

#define SETTINGS_PRODUCT_SERIAL             0x000E
#define SETTINGS_PRODUCT_MODEL              0x0010
#define SETTINGS_HW_VERSION                 0x0024
#define SETTINGS_FIRMWARE_VERSION           0x0026
#define SETTINGS_SERIAL_NUM                 0x0028

#define SETTINGS_DIRECTION_WORK_STATUS      0x0030
#define SETTINGS_DIRECTION_ERROR_STATUS     0x0034
#define SETTINGS_DIRECTION_ENABLE           0x0038
#define SETTINGS_DIRECTION_RESET            0x0039
#define SETTINGS_DIRECTION_SET_CALIB_DATA	0x003A
#define SETTINGS_DIRECTION_RECTIFY_SW       0x003B
#define SETTINGS_DIRECTION_AUTO_EXPO        0x003C
#define SETTINGS_DIRECTION_AUTO_GAIN        0x003D
#define SETTINGS_DIRECTION_EXP_OUT_ENABLE   0x003E
#define SETTINGS_DIRECTION_IS_RGB           0x0040
#define SETTINGS_DIRECTION_IS_IR            0x0041

#define SETTINGS_DIRECTION_DOE_SW           0x0043
#define SETTINGS_DIRECTION_DEPTH_SW         0x0045
#define SETTINGS_DIRECTION_REGISTRATION_SW  0x0046

#define SETTINGS_UPDATE_SIZE            	0x0048
#define SETTINGS_UPDATE_PAGE_NUM       		0x004C
#define SETTINGS_UPDATE_PAGE_INDEX     		0x004E

#define SETTINGS_CURRENT_TEMP               0x0050
#define SETTINGS_MAX_TEMP                   0x0052
#define SETTINGS_MIN_TEMP                   0x0054
#define SETTINGS_CURRENT_VCCPINT            0x0056
#define SETTINGS_MAX_VCCPINT                0x0058
#define SETTINGS_MIN_VCCPINT                0x005A
#define SETTINGS_CURRENT_VCCPAUX            0x005C
#define SETTINGS_MAX_VCCPAUX                0x005E
#define SETTINGS_MIN_VCCPAUX                0x0060
#define SETTINGS_CURRENT_VCCPDRO            0x0062
#define SETTINGS_MAX_VCCPDRO                0x0064
#define SETTINGS_MIN_VCCPDRO                0x0066
#define SETTINGS_CMOS_TEMP                  0x0068
#define SETTINGS_IMU_TEMP                   0x006A

#define SETTINGS_SYSTEM_TIMESTAMP_US		0x0070

#define SETTINGS_USB_VID            		0x00C0
#define SETTINGS_USB_PID            		0x00C2
#define SETTINGS_PRODUCT_NAME         		0x00D0

#define SETTINGS_FLASH_CMD            		0x00F0
#define SETTINGS_ERASE_TIMES            	0x00FC

#define SETTINGS_MODE                       0x0100
#define SETTINGS_SRC_IMG_HEIGH	            0x0104
#define SETTINGS_SRC_IMG_WIDTH              0x0106
#define SETTINGS_DEST_DISP_HEIGHT           0x0108
#define SETTINGS_DEST_DISP_WIDTH            0x010A
#define SETTINGS_SRC_IMG_FPS                0x010C
#define SETTINGS_DEST_DISP_FPS	            0x010D

#define SETTINGS_HTS                        0x0200
#define SETTINGS_VTS                        0x0202
#define SETTINGS_DIST_THR                   0x0204
#define SETTINGS_DESIRED_BRIGHTNESS         0x0206
#define SETTINGS_CURRENT_BRIGHTNESS         0x0207
#define SETTINGS_CURRENT_EXPOSURE           0x0208
#define SETTINGS_MAX_EXPOSURE               0x020A
#define SETTINGS_MIN_EXPOSURE               0x020C
#define SETTINGS_CURRENT_GAIN               0x020E
#define SETTINGS_MAX_GAIN                   0x0210
#define SETTINGS_MIN_GAIN                   0x0212

#define SETTINGS_PWM_DUTY                   0x0215

#define SETTINGS_CURRENT_GAIN_B           	0x02D4
#define SETTINGS_CURRENT_GAIN_G           	0x02D6
#define SETTINGS_CURRENT_GAIN_R           	0x02D8

#define SETTINGS_SM_CTRL                    0x0400
#define SETTINGS_SM_PARA                    0x0402

#define SETTINGS_CALIB_DATA	                0x0500

#define SETTINGS_IMU_DATA					0x0D00

#define SETTINGS_UPDATE_DATA	            0x0E00 // 256 char

//ADDR OFFSET
#define OFFSET_CHANNEL_CALIB_DATA			0x0100
#define OFFSET_CHANNEL_CTRL_PARA			0x0020

//BIT SET
#define BIT(x) 								(1<<(x))
#define BIT0 								BIT(0)
#define BIT1 								BIT(1)
#define BIT2 								BIT(2)
#define BIT3 								BIT(3)
#define BIT4 								BIT(4)
#define BIT5 								BIT(5)
#define BIT6 								BIT(6)
#define BIT7 								BIT(7)

//SETTINGS_WORK_STATUS
#define WORK_STATE							BIT0
#define BUSY_STATE							BIT1

//SETTINGS_UPDATE_STATUS
#define UPDATE_FLAG			BIT0
#define UPDATE_ERASE_FLAG   BIT1
#define UPDATE_TRANS_FLAG   BIT2
#define UPDATE_WRITE_FLAG   BIT3
#define UPDATE_OPRATE_FLAG  BIT4
#define UPDATE_FINISH_FLAG  BIT5

//SETTINGS_WORK_START
#define WORK_START							0x01
#define WORK_STOP							0x00

//SETTINGS_CMD
#define DEVICE_RST 							BIT0
#define IMU_OFFSET_ON						BIT1
#define IMU_OFFSET_OFF						BIT2
#define IMU_CALIB_SAVE						BIT3
#define DEVICE_HARD_RST 					BIT4
#define UPDATE_FPGA	 						BIT6
#define UPDATE_FX3	 						BIT7

//SETTINGS_ERROR_STATUS
#define CAMERA_ERROR 						BIT0
#define FLASH_ERROR 						BIT1

//SETTINGS_FLASH_CMD
#define SAVE_REG 							BIT0

//SETTINGS_SM_CTRL
#define SM_HOLE_FILL 						BIT0
#define SM_LR_CHECK 						BIT1
#define SM_SUB_PIXEL 						BIT2
#define SM_MEDIAN_FILTER 					BIT3
#define SM_RM_SKY		 					BIT4

}
